
import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";
import baseUrl from './env';

//查询学分认定列表
export function getTableList(data) {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/page`,
        method: 'post',
        data
    })
}
//保存学分认定申请
export function addExchangeInfo(data) {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/addExchangeInfo`,
        method: 'post',
        data
    })
}
//提交学分认定申请
export function checkProgress(data) {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/checkProgress`,
        method: 'post',
        data
    })
}
//查询交流名称
export function queryExchangelist(studentId) {
    return fetch({
        url: `${baseUrl}ug/exchanges/exchangesNames?studentId=${studentId}`,
        method: 'get'
    })
}
//查询非公共选修课程
export function queryNonPublicCourses(data) {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/nonPublic`,
        method: 'post',
        data
    })
}
//查询公共选修课程
export function queryPublicCourses(grade, otherParam) {
    otherParam = otherParam || {};
    let params = {
        grade,
        ...otherParam
    }
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/public`,
        method: 'get',
        params
    })
}
//查询学生交流项目跨学期数
export function getAcrossTermNum(data) {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/getAcrossTermNum?studentId=${data.studentId}&&exchangesName=${data.exchangeName}`,
        method: 'get'
    })
}
// 查询成绩记录方式
export function getScopeTypeList() {
    return fetch({
        url: `/api/scoremanagementservice/scoreSettingController/queryScoreRecord?coretypeCode=${'3'}&&projectId=${1}`,
        method: 'get'
    });
}
// 校验是否在申请范围内
export function checkTimeConfig() {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/checkTimeConfig`,
        method: 'get'
    })
}
/**
 * 学分认定PDF下载
 * @param {*} data 
 */
export function creditAuthPdf(data) {
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/creditAuthPdf`,
        responseType: 'blob',
        method: 'post',
        data
    }).then(res => {
        UTILS.downloadFile(res, '认定说明列表.zip', 'application/zip');
    });
}
/**
 * 学分认定审核、查询导出
 * @param {*} data 
 */
export function exportApplyList(data){
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/exportApplyList`,
        responseType: 'blob',
        method: 'post',
        data
    }).then(res => {
        UTILS.downloadFile(res, '学分认定列表.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}
//控制认定成绩操作权限
export function canAuditOption(id){
    return fetch({
        url: `${baseUrl}exchangesApplyInfo/canAuditOption?id=${id}`,
        method: 'get'
    })

}

// 学分认定申请页面撤销
export function creditRecall(approvalId) {
    return fetch({
        url: `${baseUrl}/exchangesApplyInfo/recall?no=${approvalId}`,
        method: 'get'
    })
}


